import jplur
import time
from random import randint, choice
from jplur.entity import *

class mapFairy:
	def __init__(self):
		self.monsters_level_count = []
		for i in range(50):
			self.monsters_level_count.append(0)
		self.update = time.time()
		
	def pump(self):
		if time.time() - self.update > .01:
			self.update = time.time()
			z = len(jplur.map.map)
			x = len(jplur.map.map[0])
			y = len(jplur.map.map[0][0])
			
			ran_p = [ randint(0,z-1), randint(0,x-1), randint(0,y-1) ]
			#get a random point in map
			#assess it
			#do something
			tile = jplur.map.tile_at(ran_p)
			if tile < 0:

				
				if self.monsters_level_count[ran_p[0]] < 160:
					self.monsters_level_count[ran_p[0]] += 1
					newguy = jplur.monster_generator.get(ran_p[0])
					entity = Monster(newguy)
					entity.location = ran_p
					entity.move([0,0,0])
					jplur.monsters.append(entity)
				
